﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace Demo11
{
    class Program
    {
        static void Main(string[] args)
        {
            Test5();
        }

        public static void Test1()
        {
            //1、生成0-5之间的随机小数，保留两位小数（必须是2位）
            Random ran = new Random();

            for (int i = 0; i < 50; i++)
            {
                double a = ran.NextDouble() * 5;
                Console.WriteLine(a.ToString("f2"));
            }
        }

        public static void Test2()
        {
            //2、生成4 - 7之间的随机小数，保留两位小数。
            Random ran = new Random();

            for (int i = 0; i < 50; i++)
            {
                double b = 4 + ran.NextDouble() * (7 - 4);
                Console.WriteLine(b.ToString("f2"));
            }
        }

        public static void Test3()
        {
            //3、生成一个随机整型数组，长度是10，内容是1~10，数组内容不重复。
            Random ran = new Random();
            int[] arr = new int[10];
            for (int i = 0; i < arr.Length;)
            {
                int a = ran.Next(0,11);
                if (Array.IndexOf(arr,a)==-1)
                {
                    arr[i] = a;
                    i++;
                }
            }
            foreach (var item in arr)
            {
                Console.Write(item+"  ");
            }


        }

        public static void Test4()
        {
            
            //4、用户输入邮箱，请验证其合法性。
            Console.WriteLine("请输入:");
            string email = Console.ReadLine();
            bool result = Regex.IsMatch(email, @"^(\w)+(\.?)(\w)*@(\w)+(\.(com|org|net|edu|mil|tv|biz|info))$");
            Console.WriteLine(result);       
        }

        public static void Test5() {
            //用户输入手机号码，请验证其合法性。
            Console.WriteLine("请输入:");
            string tel = Console.ReadLine();
            bool result = Regex.IsMatch(tel, @"^(\+86)?((13\d{1})|(14(5|7))|(15([0-3]{1}|[5-9]{1}))|(17(6|7|8))|(18\d{1}))(\d{8})$");
            Console.WriteLine(result);
        }
    }
}
